$(document).ready(init);

function init(){
	initData();
	renderPage();
	bindEvent();
}

function initData(){
	
}

function renderPage(){
	$('#uploadDemoLink').button();
}

function bindEvent(){
	$('#uploadDemoLink').click(uploadDemo);
}



function uploadDemo(){
	var option={'scriptUri':webappName+'/demo/uploadFile'};
	$(document).bind(_EVENT_ONE_FILE_UPLOAD_COMPLETE,onOneFileUploadComplete)
	util.popUploadDialog(option);
}

function onOneFileUploadComplete(event,data){
	console.debug(data);
	var fileVO = data.objects['fileVO'];
	if (data.executeResult&&fileVO.hasPreview){
		addPreview(fileVO);
	}
}

function addPreview(fileVO){
	var previewHtml = "<img height='100' width='100' src='"+fileVO.previewUri+"'></img>"
	$('#filePreviewDiv').append(previewHtml);
}